<template>
	<!-- 搜索 -->
	<view class="content">
		<view class="oper-view m-t-25">
			<view class="oper-label">扫码</view>
			<u-input v-model="inputVal" :focus="inputFocus" clearable placeholder="请扫描" @confirm="submit" @focus="inputVal = ''" />
		</view>

		<view v-if="type == 'planprocess'">
			<view class="info-body m-t-25">
				<view class="info-line">
					<view class="info-name">条码</view>
					<view class="info-val">{{ codeValue }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">订单号</view>
					<view class="info-val">{{ listInfo.salesOrderNumber }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">物料代码</view>
					<view class="info-val">{{ listInfo.productCode }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">物料名称</view>
					<view class="info-val">{{ listInfo.productName }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">规格型号</view>
					<view class="info-val">{{ listInfo.productModel }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">工序名称</view>
					<view class="info-val">{{ listInfo.processName }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">前置工序</view>
					<view class="info-val">{{ listInfo.preProcessNames }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">计划总数</view>
					<view class="info-val">{{ listInfo.planQty }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">已汇报数量</view>
					<view class="info-val">{{ listInfo.currentTurnOut }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">待汇报数量</view>
					<view class="info-val">{{ listInfo.reportedNotNums }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">是否首检</view>
					<view class="info-val">
						<text v-if="listInfo.inspectType == 1">是</text>
						<text v-else>否</text>
					</view>
				</view>
				<view class="info-line">
					<view class="info-name">首检是否合格</view>
					<view class="info-val">{{ listInfo.inspectResult }}</view>
				</view>
				<view class="info-line" style="border-bottom: none;">
					<view class="info-name">创建人</view>
					<view class="info-val">{{ listInfo.createUserName }}</view>
				</view>
			</view>

			<view v-if="listInfo.notReportDataList && listInfo.notReportDataList.length > 0">
				<view class="info-line" style="border-bottom: none;margin-top: 25rpx;"><view class="info-name" style="color: #333;font-weight: 700;">未投产信息</view></view>

				<view class="info-body m-t-25" v-for="(item, index) of listInfo.notReportDataList" :key="index">
					<view style="padding: 25rpx 0;font-weight: 700;color: #555;">{{ item.processName }}</view>
					<view class="info-line" v-for="(items, indexs) of item.boxflowDtoList" :key="indexs">
						<view class="info-name" style="color: #000;">{{ items.code}}</view>
						<view class="info-val">{{ items.qty }}</view>
					</view>
				</view>
			</view>

			<view v-if="listInfo.flowBoxCodeList && listInfo.flowBoxCodeList.length > 0">
				<view class="info-line" style="border-bottom: none;margin-top: 25rpx;"><view class="info-name" style="color: #333;font-weight: 700;">投产框信息</view></view>

				<view class="info-body m-t-25">
					<view class="info-line"  v-for="(item, index) of listInfo.flowBoxCodeList" :key="index">
						<view class="info-name" style="color: #000;">{{ item.code }}</view>
						<view class="info-val" style="color: #777;">{{ item.processStatusName }}</view>
					</view>
				</view>
			</view>

			<view v-if="listInfo.processReportList && listInfo.processReportList.length > 0">
				<view class="info-line" style="border-bottom: none;margin-top: 25rpx;"><view class="info-name" style="color: #333;font-weight: 700;">汇报框信息</view></view>

				<view class="info-body m-t-25">
					<view class="info-line" v-for="(item, index) of listInfo.processReportList" style="display: flex;justify-content:space-between">
						<view class="info-boxName" style="width: 220rpx;">{{ item.boxCodeCode }}</view>
						<view class="info-boxNum" style="width: 130rpx;">{{ item.okQty }}</view>
						<view class="info-boxPersonal"  style="width: 130rpx;">{{ item.personNames }}</view>
						<view class="info-boxStatus" style="width: 130rpx;">{{ item.boxCodeProcessStatusName }}</view>
					</view>
					<!-- <view class="info-line">
						<view class="info-name">人员</view>
						<view class="info-val">{{ item.personNames }}</view>
					</view> -->
				</view>
			</view>
		</view>

		<view class="info-body m-t-25" v-if="type == 'flowbox'">
			<view class="info-line">
				<view class="info-name">条码</view>
				<view class="info-val">{{ codeValue }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">流转卡号</view>
				<view class="info-val">{{ listInfo.planProcessCode }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">框名称</view>
				<view class="info-val">{{ listInfo.name }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">数量</view>
				<view class="info-val">{{ listInfo.qty }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">产品名称</view>
				<view class="info-val">{{ listInfo.productName }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">工序名称</view>
				<view class="info-val">{{ listInfo.processName }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">行号</view>
				<view class="info-val">{{ listInfo.seq }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">工单号</view>
				<view class="info-val">{{ listInfo.taskCode }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">销售订单号</view>
				<view class="info-val">{{ listInfo.salesOrderNumber }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">质量状态</view>
				<view class="info-val">{{ listInfo.qualityStatusName }}</view>
			</view>
			<view class="info-line">
				<view class="info-name">处理状态</view>
				<view class="info-val">{{ listInfo.processStatusName }}</view>
			</view>
			<view class="info-line" style="border-bottom: none;">
				<view class="info-name">创建人</view>
				<view class="info-val">{{ listInfo.createUserName }}</view>
			</view>
		</view>

		<view v-if="type == 'device'">
			<view v-for="(item, index) of deviceList" class="info-body m-t-25" :key="index">
				<view class="info-line">
					<view class="info-name">条码</view>
					<view class="info-val">{{ codeValue }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">设备名称</view>
					<view class="info-val">{{ item.name }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">设备编码</view>
					<view class="info-val">{{ item.code }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">规格规格</view>
					<view class="info-val">{{ item.model }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">设备类型</view>
					<view class="info-val">{{ item.deviceTypeName }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">设备状态</view>
					<view class="info-val">{{ item.deviceStatusName }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">生产状态</view>
					<view class="info-val">{{ item.productStatus }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">生产订单号</view>
					<view class="info-val">{{ item.taskCode }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">行号</view>
					<view class="info-val">{{ item.seq }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">销售订单号</view>
					<view class="info-val">{{ item.salesOrderNumber }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">投产产品</view>
					<view class="info-val">{{ item.feedProductName }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">投产工序</view>
					<view class="info-val">{{ item.feedProcessName }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">工艺步骤</view>
					<view class="info-val">{{ item.feedIdx }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">工厂</view>
					<view class="info-val">{{ item.factoryName }}</view>
				</view>
				<view class="info-line">
					<view class="info-name">备注</view>
					<view class="info-val">{{ item.remarks }}</view>
				</view>
				<view class="info-line" style="border-bottom: none;">
					<view class="info-name">创建人</view>
					<view class="info-val">{{ listInfo.createUserName }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
var that;
export default {
	data() {
		return {
			codeValue: null,
			inputVal: null,
			inputFocus: true,
			type: null,
			listInfo: null,
			deviceList: []
		};
	},
	onShow() {},
	onLoad() {
		that = this;
	},
	watch: {},
	methods: {
		submit(e) {
			console.log(e);
			this.$u
				.get('/mobile/api/queryInformation', {
					code: e
				})
				.then(res => {
					if (res.data.type == 'planprocess') {
						that.type = res.data.type;
						that.listInfo = res.data.productPlanProcessDto;
					} else if (res.data.type == 'flowbox') {
						that.type = res.data.type;
						that.listInfo = res.data.flowBoxCodeDto;
					} else if (res.data.type == 'device') {
						that.type = res.data.type;
						that.deviceList = res.data.deviceDtos;
					} else {
						uni.showToast({
							mask: true,
							icon: 'none',
							title: '暂未查询到数据'
						});
					}
					console.log(that.listInfo.flowBoxCodeList);
					that.codeValue = e;
					that.inputFocus = false;
					setTimeout(function() {
						that.inputFocus = true;
					}, 200);
				});
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #f4f5f5;
	font-size: 32rpx;
	padding-bottom: 35rpx;
}

.info-body {
	background-color: #fff;
	padding: 0 25rpx 0 25rpx;
	border-radius: 15rpx;
	background-color: #fff;
}

.info-line {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	padding: 15rpx 0;
	border-bottom: 1rpx solid #f4f5f5;
}

.info-name {
	width: 200rpx;
	color: #999;
}

.info-val {
	width: 440rpx;
	display: flex;
	justify-content: flex-end;
	color: #555;
}

.info-boxName {
	color: #000;
}

.info-boxStatus {
	text-align: right;
	color: #777;
}

.info-boxNum {
	text-align: center;
}

.info-boxPersonal {
	text-align: right;
}
</style>
